
cmake_minimum_required(VERSION 3.14)
#设置工程名字
project(examples LANGUAGES CXX)
project(examples VERSION 1.0)

set(CMAKE_AUTOUIC ON) #自动用qt的uic程序处理.ui文件
set(CMAKE_AUTOMOC ON) #自动用QT的moc程序处理
set(CMAKE_AUTORCC ON) #自动用qt的qcc程序处理资源文件

#设置支持c17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#为每个模块提供*.cmake文件搜索路径,记得在环境变量中配置QT5的目录。QT5_HOME
set(CMAKE_PREFIX_PATH  $ENV{QT5_HOME})
set(Qt5_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5")
set(Qt5Widgets_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5Widgets")
#set(Qt5Network_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5Network")
#set(Qt5LinguistTools_DIR "${CMAKE_PREFIX_PATH}/lib/cmake/Qt5LinguistTools")
find_package(Qt5 REQUIRED COMPONENTS Widgets)

#设置cmake的运行目录
set(PROJECT_BINARY_DIR ${PROJECT_SOURCE_DIR}/../build/examples)

#将上级目录（../下的所有文件）放入SOURCE_LIST,注意这里的目录要以cmake的运行目录为相对目录
FILE(GLOB_RECURSE source_file_list *.h *.cpp *.ui *.qrc)
set(PROJECT_SOURCES ${source_file_list} )

FOREACH(file ${source_file_list})
message(STATUS "[FIle] Found ::: ${file}")
ENDFOREACH()

#设置包含文件目录
include_directories(.)
include_directories(../fcbwidgets)

#设置静态库文件目录
link_directories(${PROJECT_SOURCE_DIR}/../debug)

 

#指定编译为静态库STATIC,要编译动态库，SHARED  ,可以同时输出静态库和动态库
add_executable(examples     ${PROJECT_SOURCES})
#设置编译输出的文件名 ,不用指定开始的lib,这一句也可以不写，默认就add_library的第一个参数名
set_target_properties(examples PROPERTIES OUTPUT_NAME "examples")
 
#将对应的库连接到目标，类似与QT的pro文件的 -l  ,这里的第一个参数是add_library的第一个参数名.
target_link_libraries(examples PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
# target_link_libraries(examples PRIVATE Qt${QT_VERSION_MAJOR}::Network)
# target_link_libraries(examples PRIVATE Qt${QT_VERSION_MAJOR}::Qml)
# target_link_libraries(examples PRIVATE Qt${QT_VERSION_MAJOR}::Quick)

target_link_libraries(examples PRIVATE libfcbwidgets.a)

 
#设置目录 EXECUTABLE_OUTPUT_PATH为CMakeLists.txt所在目录
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../../debug)
 
 
